import { HTTP } from '../common/utils/http'

class CartModel extends HTTP {
    // 获取购物车列表
    getCartList() {
        return this.request({
            url: '/api/shop_carts/list'
        })
    }
    // 添加商品到购物车
    addCommidtyToCart(data) {
        return this.request({
            url: '/api/shop_carts/create',
            method: 'POST',
            data
        })
    }
    // 购物车加号操作
    cartAddNumber(data) {
        return this.request({
            url: '/api/shop_carts/add',
            method: 'POST',
            data
        })
    }
    // 购物车减号操作
    cartSubNumber(data) {
        return this.request({
            url: '/api/shop_carts/subtract',
            method: 'POST',
            data
        })
    }
    // 购物车删除商品
    delCartGoods(id) {
        return this.request({
            url: `/api/shop_carts/delete/${id}`,
            method: 'POST'
        })
    }
    // 购物车结算创建订单
    addCartOrder(data) {
        return this.request({
            url: '/api/shop_carts/create_order',
            method: 'POST',
            data
        })
    }
}

export { CartModel }